<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Cities_spain_entity{
	var $current_dbprefix = "";
	var $CI;
	var $id = 0;
	var $province_code = '';
	var $city_code = '';
	var $city_name_spanish = '';
	 
	function __construct() {
		$this->CI= & get_instance();
		$this->current_dbprefix = $this->CI->db->dbprefix;
		$this->CI->db->set_dbprefix('default_');
	}
	function __destruct() {
		$this->CI->db->set_dbprefix($this->current_dbprefix);
	}
	function init($cmd, $input)
	{	
		$this->CI->db->set_dbprefix('default_');
		
		if($cmd == 'id')
		{
			$result = $this->CI->db->where('id',$input)->get(TBL_SPAIN_CITY)->result();
		}
		else
		{
			return false;
		}
		if( !empty($result) )
		{
			$this->id = $result[0]->id;
			$this->province_code = $result[0]->province_code;
			$this->city_code = $result[0]->city_code;
			$this->city_name_spanish = $result[0]->city_name_spanish;
			return $this;
		}
		return false;
	}
	
	function getId(){return $this->id;}
	function getProvinceCode(){return $this->province_code;}
	function getCityCode(){return $this->city_code;}	
	function getCityNameSpanish(){return $this->city_name_spanish;}
	//end class
}	